<template>
	<view>
		<!-- 我的应价 -->
		<view class="bg-white p-2" style="width: 2000rpx;">
			<view v-if="select==0" class="">
				<view class="flex font-md align-center">
					<view @click="selectActive(index)" class="p-2 px-4" :class="active==index?'active':''"
						v-for="(item,index) in navData" :key="index">
						<text>{{item.name}}</text>
						<text>({{item.value}})</text>
					</view>
				</view>
				<view class="p-2 flex justify-center flex-column"
					style="background-color: rgb(249,249,249);flex-wrap: wrap;">
					<view class="flex mb-3 align-center">
						<view class="flex align-center mr-4">
							<view class="ml-2 flex align-center px-2">
								<uni-easyinput v-model.trim="form.Article_Name" placeholder="请输入商品名称"></uni-easyinput>
							</view>
						</view>
						<view class="flex align-center mr-4">
							<button @click="goPosting()" class="uni-button" size="mini" type="primary">发布</button>
						</view>
						<view class="flex align-center mr-4">
							<uni-badge class="uni-badge-left-margin" :text="value" absolute="rightTop" size="small">
								<view class="">
									<button @click="show(form1)" class="uni-button" size="mini"
										type="primary">我的求购</button>
								</view>
							</uni-badge>
						</view>
						<view class="flex align-center mr-4">
							<uni-badge class="uni-badge-left-margin" :text="value" absolute="rightTop" size="small">
								<view class="">
									<button @click="goMessage()" class="uni-button" style="background-color: #eee;"
										size="mini" type="info">消息</button>
								</view>
							</uni-badge>
						</view>
						<view class="flex">
							<view @click="Inquire()" class="text-white bg-orange px-4 py-2 text-center mr-2"
								style="border-radius: 10rpx;">
								<text>查询</text>
							</view>
							<view @click="reset()" class="text-white bg-orange px-4 py-2 text-center"
								style="border-radius: 10rpx;">
								<text>重置</text>
							</view>
						</view>
					</view>
				</view>
				<view class="">
					<!-- 表格 -->
					<view class="mt-2">
						<!-- 表格 -->
						<el-table @expand-change="expandChange" border :data="MessageData" style="width: 100%">
							<el-table-column type="expand" align="center">
								<template slot-scope="props">
									<el-table border :data="MyPurchasesData">
										<el-table-column align="center" label="总数量" prop="Total_Quantity">
										</el-table-column>
										<el-table-column align="center" label="收购量" prop="Quantity">
										</el-table-column>
										<el-table-column align="center" label="价格" prop="Amount">
										</el-table-column>
										<el-table-column align="center" label="所属企业" prop="Enterprise_Name">
										</el-table-column>
										<el-table-column min-width="100" align="center" label="联系人"
											prop="Seller_Contact">
										</el-table-column>
										<el-table-column align="center" label="联系人电话" prop="Seller_Contact_Phone">
										</el-table-column>
										<el-table-column align="center" label="包装方式" prop="Transport_Type">
										</el-table-column>
										<el-table-column align="center" label="支付方式" prop="Trading_Type">
										</el-table-column>
										<el-table-column align="center" label="付款方式" prop="Payment_Type">
										</el-table-column>
										<el-table-column align="center" label="物流方式" prop="Shipment_Type">
										</el-table-column>
										<el-table-column align="center" label="状态" prop="Row_Status">
										</el-table-column>
										<el-table-column align="center" label="预约时间" prop="Submission_Time">
										</el-table-column>
										<el-table-column min-width="180" align="center" label="操作">
											<template slot-scope="props">
												<view class="flex justify-center">
													<view class="">
														<button v-if="props.row.Row_Status == '0'" @click="Inventory(props)"
															:disabled="disabled"
															style=";text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
															class="uni-button flex justify-center mr-2" size="mini"
															type="primary">通过</button>
													</view>
													<view class="">
														<button v-if="props.row.Row_Status == '0'"
															@click="RefuseProcurement(props.row)" :disabled="disabled"
															style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
															class="uni-button flex justify-center mr-2" size="mini"
															type="warn">拒绝</button>
													</view>
													<view class="">
														<button @click="Detail(props.row,1)"
															style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
															class="uni-button flex justify-center mr-2"
															size="mini">详情</button>
													</view>
													<view class="">
														<button v-if="props.row.Row_Status == '1'"
															@click="getDatas(props.row.Group_Seek_Purchase_SerialNumber,props.row.Group_Seek_Transaction_SerialNumber)"
															style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
															class="uni-button flex justify-center" size="mini"
															type="primary">确认合同</button>
													</view>
													<view class="">
														<button v-if="props.row.Row_Status == '5'"
															@click="ConfirmReceipt(props.row)"
															style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
															class="uni-button flex justify-center mr-2"
															size="mini">确认收货</button>
													</view>
												</view>
											</template>
										</el-table-column>
									</el-table>
								</template>
							</el-table-column>
							<el-table-column align="center" label="序号" type="index" :index="indexMethod">
							</el-table-column>
							<el-table-column align="center" label="商品名称" prop="Article_Name">
							</el-table-column>
							<el-table-column align="center" label="状态">
								<text>求购中</text>
							</el-table-column>
							<el-table-column align="center" label="需求总量" prop="Total_Quantity">
							</el-table-column>
							<el-table-column align="center" label="起步量" prop="Starting_Quantity">
							</el-table-column>
							<el-table-column align="center" label="已收购量" prop="Acquisition_Quantity">
							</el-table-column>
							<el-table-column min-width="100" align="center" label="剩余需求量" prop="Residue_Quantity">
							</el-table-column>
							<el-table-column align="center" label="商品价格" prop="Amount">
							</el-table-column>
							<el-table-column align="center" label="联系人" prop="Contacts">
							</el-table-column>
							<el-table-column align="center" label="企业名称" prop="Enterprise_Name">
							</el-table-column>
							<el-table-column min-width="180" align="center" label="操作">
								<view class="flex">
									<button @click="show(form1)" class="uni-button" size="mini"
										type="primary">查看</button>
									<button class="uni-button" size="mini" type="warn">取消需求</button>
								</view>
							</el-table-column>
						</el-table>
					</view>
					<view v-if="MessageData.length>0" class="py-2 pr-2" style="background-color: rgb(248,249,250);">
						<view class="flex align-center justify-end">
							<text class="mx-2">共{{total}}页</text>
							<view class="flex align-center">
								<button @click="previousPage" :disabled="active3==0" style="width: 10px; height: 30px;"
									class="flex align-center justify-center">
									<uni-icons :color="(active3==0?'gray':'black')" type="left"></uni-icons>
								</button>
								<text :class="(active3==index?'getPages':'bgc')+' mx-2 text-center' "
									@click="getPages(index)" style=" line-height: 30px; width: 30px; height: 30px;"
									v-for="(item,index) in total" :key="index">{{index+1}}</text>
								<button @click="nextPage" :disabled="active3==total-1"
									style="width: 10px; height: 30px;" class="flex align-center justify-center">
									<uni-icons :color="(active3==total-1?'gray':'black')" type="right"></uni-icons>
								</button>
							</view>
							<view class="ml-3 flex align-center justify-center">
								<text>前往</text>
								<input class="border rounded text-center mx-2" style="width: 40px;" type="number"
									@keydown.enter="enter" v-model.number="active4">
								<text>页</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="select==1" class="">
				<view class="">
					<view v-if="false" class="flex py-2">
						<view class="flex align-center mr-4">
							<view class="flex align-center px-2">
								<uni-easyinput v-model.trim="form1.Article_Name" placeholder="请输入商品名称"></uni-easyinput>
							</view>
						</view>
						<view class="flex">
							<view @click="Inquire()" class="text-white bg-orange px-4 py-2 text-center mr-2"
								style="border-radius: 10rpx;">
								<text>查询</text>
							</view>
							<view @click="reset()" class="text-white bg-orange px-4 py-2 text-center"
								style="border-radius: 10rpx;">
								<text>重置</text>
							</view>
						</view>
					</view>
					<!-- 表格 -->
					<uni-table border :loading="loading" stripe emptyText="暂无更多数据">
						<!-- 表头行 -->
						<uni-tr>
							<uni-th width="60" align="center">序号</uni-th>
							<uni-th width="80" align="center">商品名</uni-th>
							<uni-th width="70" align="center">总数量</uni-th>
							<uni-th width="80" align="center">收购量</uni-th>
							<uni-th width="70" align="center">价格</uni-th>
							<uni-th width="90" align="center">所属企业</uni-th>
							<uni-th width="95" align="center">联系人</uni-th>
							<uni-th width="80" align="center">联系人电话</uni-th>
							<uni-th width="90" align="center">包装方式</uni-th>
							<uni-th width="90" align="center">支付方式</uni-th>
							<uni-th width="90" align="center">付款方式</uni-th>
							<uni-th width="90" align="center">物流方式</uni-th>
							<uni-th width="80" align="center">状态</uni-th>
							<uni-th width="150" align="center">预约时间</uni-th>
							<uni-th width="200" align="center">操作</uni-th>
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr v-for="(item,i) in MyPurchasesData" :key="i">
							<uni-td align="center">{{i+1}}</uni-td>
							<uni-td align="center">
								<view :title="item.Article_Name" style="width: 110rpx;"
									class="text-ellipsis text-center">
									<text>{{item.Article_Name}}</text>
								</view>
							</uni-td>
							<uni-td align="center">{{item.Total_Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
							<uni-td align="center">{{item.Quantity}}{{item.Article_Unit_SerialNumber}}</uni-td>
							<uni-td align="center">￥{{item.Amount}}</uni-td>
							<uni-td align="center">
								<view :title="item.Enterprise_Name" style="width: 110rpx;"
									class="text-ellipsis text-center">
									<text>{{item.Enterprise_Name}}</text>
								</view>
							</uni-td>
							<uni-td align="center">{{item.Seller_Contact}}</uni-td>
							<uni-td align="center">{{item.Seller_Contact_Phone}}</uni-td>
							<uni-td align="center">{{item.Transport_Type}}</uni-td>
							<uni-td align="center">{{item.Trading_Type=='1'?'按阶段付款':'全款'}}</uni-td>
							<uni-td align="center">{{item.Payment_Type}}</uni-td>
							<uni-td align="center">{{item.Shipment_Type}}</uni-td>
							<uni-td align="center">
								<text v-if="item.Row_Status == '0'">审核中</text>
								<text
									v-if="(item.Row_Status == '1'||item.Row_Status == '4')&&item.Seller_Status=='0'">待确认合同</text>
								<text v-if="item.Row_Status == '1'&&item.Seller_Status=='4'">待对方确认</text>
								<text
									v-if="item.Row_Status == '4'&&item.Seller_Status=='4'&&item.Paystages.split('/')[0]=='0'">待付首款</text>
								<text
									v-if="item.Row_Status == '4'&&item.Seller_Status=='4'&&item.Paystages.split('/')[0]=='1'">待发货</text>
								<text v-if="item.Row_Status == '5'">待收货</text>
								<text v-if="item.Row_Status == '6'&&item.Pay_Status=='0'">待付剩余款</text>
								<text v-if="item.Row_Status == '6'&&item.Pay_Status=='1'">交易结束</text>
							</uni-td>
							<uni-td align="center">{{item.Submission_Time}}</uni-td>
							<uni-td align="center">
								<view class="flex justify-center">
									<view class="">
										<button v-if="item.Row_Status == '0'" @click="Inventory(item)"
											:disabled="disabled"
											style=";text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
											class="uni-button flex justify-center mr-2" size="mini"
											type="primary">通过</button>
									</view>
									<view class="">
										<button v-if="item.Row_Status == '0'" @click="RefuseProcurement(item)"
											:disabled="disabled"
											style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
											class="uni-button flex justify-center mr-2" size="mini"
											type="warn">拒绝</button>
									</view>
									<view class="">
										<button @click="Detail(item,i)"
											style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
											class="uni-button flex justify-center mr-2" size="mini">详情</button>
									</view>
									<view class="">
										<button v-if="item.Row_Status == '1'"
											@click="getDatas(item.Group_Seek_Purchase_SerialNumber,item.Group_Seek_Transaction_SerialNumber)"
											style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
											class="uni-button flex justify-center" size="mini"
											type="primary">确认合同</button>
									</view>
									<view class="">
										<button v-if="item.Row_Status == '5'" @click="ConfirmReceipt(item)"
											style="text-align: center;height: 80rpx;line-height: 80rpx;white-space: nowrap;"
											class="uni-button flex justify-center mr-2" size="mini">确认收货</button>
									</view>
								</view>
							</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view v-if="MessageData.length>0" class="py-2 pr-2 flex justify-between align-center"
					style="background-color: rgb(248,249,250);">
					<view class="flex align-center">
						<button @click="back()" class="uni-button" size="mini" type="primary">返回上一页</button>
					</view>
					<view class="flex align-center justify-end">
						<text class="mx-2">共{{total}}页</text>
						<view class="flex align-center">
							<button @click="previousPage" :disabled="active3==0" style="width: 10px; height: 30px;"
								class="flex align-center justify-center">
								<uni-icons :color="(active3==0?'gray':'black')" type="left"></uni-icons>
							</button>
							<text :class="(active3==index?'getPages':'bgc')+' mx-2 text-center' "
								@click="getPages(index)" style=" line-height: 30px; width: 30px; height: 30px;"
								v-for="(item,index) in total" :key="index">{{index+1}}</text>
							<button @click="nextPage" :disabled="active3==total-1" style="width: 10px; height: 30px;"
								class="flex align-center justify-center">
								<uni-icons :color="(active3==total-1?'gray':'black')" type="right"></uni-icons>
							</button>
						</view>
						<view class="ml-3 flex align-center justify-center">
							<text>前往</text>
							<input class="border rounded text-center mx-2" style="width: 40px;" type="number"
								@keydown.enter="enter" v-model.number="active4">
							<text>页</text>
						</view>
					</view>
				</view>
			</view>
			<view v-if="select==2" class="">
				<text class="h3 font-weight-bold">标品信息</text>
				<uni-table border stripe emptyText="暂无更多数据">
					<!-- 表头行 -->
					<uni-tr>
						<uni-th width="40" align="center">商品名称</uni-th>
						<uni-th width="40" align="center">挂单标题</uni-th>
						<uni-th width="40" align="center">保证方式</uni-th>
						<uni-th width="40" align="center">价格</uni-th>
						<uni-th width="40" align="center">商品总量</uni-th>
						<uni-th width="40" align="center">类别</uni-th>
						<uni-th width="50" align="center">联系人</uni-th>
						<uni-th width="40" align="center">联系人手机号</uni-th>
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr>
						<uni-td align="center">{{form3.Article_Name}}</uni-td>
						<uni-td align="center">{{form3.Group_Seek_Purchase_Name}}</uni-td>
						<uni-td align="center">{{form3.Guarantee_Method}}</uni-td>
						<uni-td align="center">￥{{form3.Amount}}</uni-td>
						<uni-td align="center">{{form3.Total_Quantity}}{{form3.Article_Unit_SerialNumber}}</uni-td>
						<uni-td align="center">{{form3.Category_Name}}</uni-td>
						<uni-td align="center">{{form3.Contacts}}</uni-td>
						<uni-td align="center">{{form3.Contacts_Phone}}</uni-td>
					</uni-tr>
					<!-- 表头行 -->
					<uni-tr>
						<uni-th width="40" align="center">企业名称</uni-th>
						<uni-th width="60" align="center">交易时间</uni-th>
						<uni-th width="40" align="center">交易地点</uni-th>
						<uni-th width="60" align="center">质量验收方式</uni-th>
						<uni-th width="60" align="center">数量验收方式</uni-th>
						<uni-th width="70" align="center">交收方式</uni-th>
						<uni-th width="40" align="center">最低购买量</uni-th>
						<uni-th width="30" align="center">补充条款</uni-th>
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr>
						<uni-td align="center">
							<view :title="form3.Enterprise_Name" class="w-100 flex justify-center text-ellipsis">
								<view class="flex justify-center text-ellipsis" style="width: 150rpx;">
									<text class="text-ellipsis">{{form3.Enterprise_Name}}</text>
								</view>
							</view>
						</uni-td>
						<uni-td align="center">{{form3.Delivery_Time}}</uni-td>
						<uni-td align="center">{{form3.Transaction_Location}}</uni-td>
						<uni-td align="center">
							<text v-if="form3.Quality_Acceptance_Method=='0'">进货检验</text>
							<text v-else-if="form3.Quality_Acceptance_Method=='1'">过程检验</text>
							<text v-else-if="form3.Quality_Acceptance_Method=='2'">现场检验</text>
							<text v-else-if="form3.Quality_Acceptance_Method=='3'">抽样检验</text>
						</uni-td>
						<uni-td align="center">
							<text v-if="form3.Quantity_Acceptance_Method=='0'">斤检法</text>
							<text v-else-if="form3.Quantity_Acceptance_Method=='1'">计件法</text>
							<text v-else-if="form3.Quantity_Acceptance_Method=='2'">检尺求积法</text>
						</uni-td>
						<uni-td align="center">
							<text v-if="form3.Delivery_Method=='1'">正常交收</text>
							<text v-else>协议交收</text>
						</uni-td>
						<uni-td align="center">{{form3.Starting_Quantity}}{{form3.Article_Unit_SerialNumber}}</uni-td>
						<uni-td align="center">{{form3.Supplementary_Provisions}}</uni-td>
					</uni-tr>
				</uni-table>
				<text class="h3 font-weight-bold">买家信息</text>
				<view class="flex justify-center">
					<view class="flex align-center my-2 justify-between" style="width: 70%;">
						<view class="flex align-center">
							<text class="mr-2">买方姓名:</text>
							<text>{{group_seek_transaction_form.Seller_Contact}}</text>
						</view>
						<view class="flex align-center">
							<text class="mr-2">买方手机号:</text>
							<text>{{group_seek_transaction_form.Seller_Contact_Phone}}</text>
						</view>
					</view>
				</view>
				<text class="h3 font-weight-bold">交收方式</text>
				<view class="flex justify-center">
					<view class="flex align-center my-2 justify-between" style="width: 70%;">
						<view class="flex align-center">
							<text>付款方式:</text>
							<text>{{Payment_Type}}</text>
						</view>
						<view class="flex align-center">
							<text>装运方式:</text>
							<text>{{Transport_Type}}</text>
						</view>
						<view class="flex align-center">
							<text>运输方式:</text>
							<text>{{Shipment_Type}}</text>
						</view>
					</view>
				</view>
				<text class="h3 font-weight-bold">进行付款</text>
				<view class="">
					<view v-if="form3.Trading_Type=='1'" class="flex flex-column">
						<view v-for="(item,i) in TradingWay" :key="i" class="flex align-center w-100 p-2"
							style="justify-content: space-evenly;">
							<view class="flex align-center">
								<text class="font-md font-weight-bold">付款{{i+1}}阶段:</text>
								<text class="font-sm ml-2">{{item.Trading_Name}}</text>
							</view>
							<view class="flex align-center">
								<text class="font-md font-weight-bold">付款额度:</text>
								<text class="font-sm text-orange ml-2">{{item.Trading_Amount}}%</text>
							</view>
							<view class="flex align-center">
								<text class="font-md font-weight-bold">最晚付款时间:</text>
								<text>{{i+1}}阶段完成后</text>
								<text v-if="item.Trading_Date=='0'">立即发货</text>
								<text v-else>第{{item.Trading_Date}}天</text>
							</view>
							<view class="flex align-center">
								<button v-if="item.Row_Status=='0'"
									@click="toggle('center',item.Group_Seek_Paystages_SerialNumber)" size="mini"
									type="primary" class="uni-button">选择付款方式</button>
								<button v-else size="mini" type="warn" class="uni-button">已付款</button>
							</view>
						</view>
					</view>
					<view v-else class="flex align-center justify-center">
						<view class="flex align-center">
							<text class="font-md font-weight-bold">全额付款:</text>
							<text class="font-sm ml-2">发货即付款</text>
						</view>
						<view class="ml-2">
							<button @click="toggle('center')" size="mini" type="primary"
								class="uni-button">选择付款方式</button>
							<button size="mini" type="warn" class="uni-button">已付款</button>
						</view>
					</view>
				</view>
				<view class="flex justify-center w-100">
					<button class="uni-button" type="primary" size="mini" @click="show(form1)">返回</button>
				</view>
			</view>
		</view>
		<Notify :show="LetterCommitment" :content="message" :type="type"></Notify>
		<uni-popup ref="popup" background-color="#fff" @change="change">
			<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
				<view class="flex flex-column align-center justify-center" style="width: 1000rpx;height: 800rpx;">
					<text class="text-center mb-2 font-weight-bold h2">请选择支付方式</text>
					<radio-group class="flex w-100" style="justify-content: space-around;" @change="radioChange">
						<label class="uni-list-cell uni-list-cell-pd flex justify-center" v-for="(item, index) in items"
							:key="item.value">
							<view class="flex align-center flex-column">
								<image style="width: 100rpx;" :src="item.Image" mode="widthFix"></image>
								<radio :value="item.value" :checked="index === current" />
								<view>{{item.name}}</view>
							</view>
						</label>
					</radio-group>
					<view class="mt-3 flex justify-center">
						<view class="flex align-center flex-column" v-if="payWay!='E-invoicing'">
							<uqrcode ref="uqrcode" canvas-id="qrcode" :value="payURL" :options="{ margin: 10 }">
							</uqrcode>
							<button @click="getOr()" class="uni-button" type="primary" size="mini">支付完成后点击此处</button>
						</view>
						<view v-else class="example-body flex justify-center flex-column align-center">
							<uni-file-picker :image-styles="imageStyles" limit="1" title="请上传电子发票"></uni-file-picker>
							<button @click="submit()" class="uni-button" type="primary" size="mini">提交</button>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import Notify from '@/components/Notify/Notify.vue'
	import times from '@/mixins/time.js'
	const app = getApp()
	export default {
		name: "MyOffer",
		data() {
			return {
				form: {
					Article_Name: "",
					Category_SerialNumber: "",
					Enterprise_Info_SerialNumber: "",
					Type: "1",
					token: "",
					page: 1, //页数
					limit: 5, //每页数据条数
				},
				form1: {
					// Article_Name: "",
					Type: "1",
					Group_Seek_Purchase_SerialNumber: '',
					token: "",
					Enterprise_Info_SerialNumber: "",
					page: 1, //页数
					limit: 999, //每页数据条数
				},
				form2: {},
				form3: {},
				group_seek_transaction_form: {
					Children: {
						group_seek_transaction_paystages: []
					}
				},
				formData: {
					Group_Seek_Transaction_SerialNumber: "", //主键
					Group_Purchasing_SerialNumber: "", //流水号
					Quantity: "", //总量
					Amount: "", //钱
					Submission_Time: "", //时间
					Trading_Type: "",
					Shipment_Type: "",
					Transport_Type: "",
					Payment_Type: "",
					Buyer_Contact: "", //买主姓名
					Buyer_Contact_Phone: "", //买主手机号
					Buyer_Enterprise_Info_SerialNumber: "", //买主公司编号
					Enterprise_Info_SerialNumber: "", //卖家公司编号
					Children: {
						group_seek_transaction_paystages: []
					}
				},
				items: [{
						value: 'wx',
						name: '微信',
						checked: 'true',
						Image: '/static/WXlogo.png'
					},
					{
						value: 'zfb',
						name: '支付宝',
						Image: '/static/zfb.png'
					},
					{
						value: 'E-invoicing',
						name: '电子汇账',
						Image: '/static/dzhz.png'
					},
				],
				imageStyles: {
					width: 150,
					height: 150,
					border: {
						width: 2,
						style: 'dashed',
						radius: '2px'
					}
				},
				payWay: 'wx',
				current: 0,
				payURL: '',
				TradingWay: [],
				PaystagesData: [],
				value: 2,
				disabled: false,
				select: 0,
				Domain_IMG: app.globalData.Domain_IMG,
				loading: true,
				LetterCommitment: false,
				type: 'info',
				message: '',
				limit: 0,
				total: 0,
				active3: 0, // 分页器换颜色
				active4: 0,
				MessageData: [],
				Payment_Type: "",
				Shipment_Type: "",
				Transport_Type: "",
				MyPurchasesData: [],
				active: 0,
				types: 'center',
				navData: [{
					name: '全部',
					value: 0
				}, ]
			};
		},
		mounted() {
			this.form.token = uni.getStorageSync('token')
			this.form.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
			this.active4 = this.active3 + 1
			this.getData(this.form)
			this.form1.token = uni.getStorageSync('token')
			this.form1.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
		},
		methods: {
			selectActive(index) {
				this.active = index
			},
			change(e) {
				console.log(e)
			},
			radioChange: function(evt) {
				console.log(evt)
				this.payWay = evt.detail.value
				for (let i = 0; i < this.items.length; i++) {
					if (this.items[i].value === evt.detail.value) {
						this.current = i;
						break;
					}
				}
			},
			goMessage() {
				uni.navigateTo({
					url: '/pages/MyMessage/MyMessage?id=1.1&kid=1'
				})
			},
			show(data) {
				this.select = 1
				this.loading = true
				this.active3 = 0
				this.active4 = this.active3 + 1
				this.limit = 0
				this.total = 0
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/getGroupSeekTransactionAllAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						this.loading = false
						console.log(res.data)
						this.MyPurchasesData = res.data.tableData
						this.limit = res.data.limit
						if (this.limit % this.form1.limit != 0) {
							this.total = Math.floor(this.limit / this.form1.limit) + 1
						} else {
							this.total = Math.floor(this.limit / this.form1.limit)
						}
					}
				})
			},
			getData(data) {
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/getGroupSeekProcureAllAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						this.loading = false
						this.MessageData = res.data.tableData
						console.log(res.data);
						this.limit = res.data.limit
						this.navData[0].value = this.limit
						if (this.limit % this.form.limit != 0) {
							this.total = Math.floor(this.limit / this.form.limit) + 1
						} else {
							this.total = Math.floor(this.limit / this.form.limit)
						}
					}
				})
			},
			getPages(index) {
				if (this.select == 0) {
					if (this.form.page == index + 1) {
						return
					}
					this.active3 = index;
					this.active4 = this.active3 + 1
					this.form.page = index + 1
					this.loading = true
					this.getData(this.form)
				}
				//  else if (this.select == 1) {
				// 	if (this.form1.page == index + 1) {
				// 		return
				// 	}
				// 	this.active3 = index;
				// 	this.active4 = this.active3 + 1
				// 	this.form1.page = index + 1
				// 	this.loading = true
				// 	this.getTransactionhistory(this.form1)
				// }
			},
			enter(e) {
				//如果输入框的值不为空
				if (this.select == 0) {
					if (e.detail.value != '') {
						//如果输入框的值超过总页数
						if (this.active4 > this.total) {
							//输入框的值强制为总页数
							this.active4 = this.total
						} else if (this.active4 <= 0) { //如果输入框的值为小于0
							//输入框的值强制为1
							this.active4 = 1
						}
						//如果输入框的值为小数则四舍五入转整数
						if (this.active4 > 1) {
							this.active4 = Math.floor(this.active4)
						} else {
							this.active4 = 1
						}
						this.active3 = this.active4 - 1
						//如果输入框的值与当前请求的值相等则不允许发送请求
						if (this.form.page == this.active4) {
							return
						}
						//把处理过后的输入框值赋值给请求
						this.form.page = this.active4
						this.loading = true
						this.getData(this.form)
					}
				}
				// } else if (this.select == 1) {
				// 	if (e.detail.value != '') {
				// 		//如果输入框的值超过总页数
				// 		if (this.active4 > this.total) {
				// 			//输入框的值强制为总页数
				// 			this.active4 = this.total
				// 		} else if (this.active4 <= 0) { //如果输入框的值为小于0
				// 			//输入框的值强制为1
				// 			this.active4 = 1
				// 		}
				// 		//如果输入框的值为小数则四舍五入转整数
				// 		if (this.active4 > 1) {
				// 			this.active4 = Math.floor(this.active4)
				// 		} else {
				// 			this.active4 = 1
				// 		}
				// 		this.active3 = this.active4 - 1
				// 		//如果输入框的值与当前请求的值相等则不允许发送请求
				// 		if (this.form1.page == this.active4) {
				// 			return
				// 		}
				// 		//把处理过后的输入框值赋值给请求
				// 		this.form1.page = this.active4
				// 		this.loading = true
				// 		this.getTransactionhistory(this.form1)
				// 	}
				// }
			},
			Inquire() {
				if (this.select == 0) {
					if (this.form.Article_Name == '') {
						this.LetterCommitment = true
						this.type = 'error'
						this.message = '请输入商品名称再进行查询'
						setTimeout(() => {
							this.LetterCommitment = false
						}, 2000)
						return
					}
					this.loading = true
					this.form.page = 1
					this.getData(this.form)
				} else if (this.select == 1) {
					if (this.form1.Article_Name == '') {
						this.LetterCommitment = true
						this.type = 'error'
						this.message = '请输入商品名称再进行查询'
						setTimeout(() => {
							this.LetterCommitment = false
						}, 2000)
						return
					}
					this.loading = true
					this.form1.page = 1
					this.show(this.form1)
				}
			},
			nextPage() {
				if (this.select == 0) {
					this.active3++
					this.active4 = this.active3 + 1
					this.form.page++
					this.loading = true
					this.getData(this.form)
				}
				// } else if (this.select == 1) {
				// 	this.active3++
				// 	this.active4 = this.active3 + 1
				// 	this.form1.page++
				// 	this.loading = true
				// 	this.getTransactionhistory(this.form1)
				// }
			},
			previousPage() {
				if (this.select == 0) {
					this.active3--
					this.active4 = this.active3 + 1
					this.form.page--
					this.loading = true
					this.getData(this.form)
				}
				// } else if (this.select == 1) {
				// 	this.active3--
				// 	this.active4 = this.active3 + 1
				// 	this.form1.page--
				// 	this.loading = true
				// 	this.getTransactionhistory(this.form1)
				// }
			},
			reset() {
				this.loading = true
				this.form = {
						Article_Name: "",
						Category_SerialNumber: "",
						Enterprise_Info_SerialNumber: "",
						Type: "1",
						token: "",
						page: 1, //页数
						limit: 5, //每页数据条数
					},
					this.form.token = uni.getStorageSync('token')
				this.form.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
				this.active3 = 0
				this.active4 = this.active3 + 1
				this.total = 1
				this.getData(this.form)
			},
			back() {
				this.select = 0
				this.active3 = 0
				this.active4 = this.active3 + 1
				this.limit = 0
				this.total = 0
				this.form = {
						Article_Name: "",
						Category_SerialNumber: "",
						Enterprise_Info_SerialNumber: "",
						Type: "1",
						token: "",
						page: 1, //页数
						limit: 5, //每页数据条数
					},
					this.form.token = uni.getStorageSync('token')
				this.form.Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
				this.getData(this.form)
			},
			Detail(item, i) {
				console.log(item, i)
				this.Transport_Type = this.MyPurchasesData[i].Transport_Type
				this.Shipment_Type = this.MyPurchasesData[i].Shipment_Type
				this.Payment_Type = this.MyPurchasesData[i].Payment_Type
				var token = uni.getStorageSync('token')
				this.select = 2
				uni.request({ //确认招采信息
					url: app.globalData.Domain_Name + '/getGroupSeekProcureIDAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Seek_Purchase_SerialNumber: item.Group_Seek_Purchase_SerialNumber,
						token
					},
					success: (res) => {
						this.form3 = res.data.Data
						console.log(this.form3)
					}
				})
				let obj = {
					// 求购信息表
					group_seek_transaction: {
						group_seek_transaction_paystages: {}
					}
				}
				uni.request({ //确认招采信息
					url: app.globalData.Domain_Name + '/getSubtableInquiryOriginal',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Primary_Key: item.Group_Seek_Transaction_SerialNumber,
						JSONObject: JSON.stringify(obj),
						token,
					},
					success: (res) => {
						this.group_seek_transaction_form = res.data.group_seek_transaction[0]
						console.log(this.group_seek_transaction_form)
					}
				})
				var Enterprise_Info_SerialNumber = uni.getStorageSync('enterprise')
				this.getPayStage(item)
			},
			indexMethod(index) {
				return index + 1
			},
			expandChange(e) {
				var data = this.form1
				data.Group_Seek_Purchase_SerialNumber = e.Group_Seek_Purchase_SerialNumber
				uni.request({ //获取所有招标信息
					url: app.globalData.Domain_Name + '/getGroupSeekTransactionAllAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						this.loading = false
						this.MyPurchasesData = res.data.tableData
						// this.limit = res.data.limit
						// if (this.limit % this.form1.limit != 0) {
						// 	this.total = Math.floor(this.limit / this.form1.limit) + 1
						// } else {
						// 	this.total = Math.floor(this.limit / this.form1.limit)
						// }
					}
				})
			},
			goPosting() {
				uni.navigateTo({
					url: '/pages/Posting/Posting'
				})
			},
			Inventory(item) {
				console.log(item)
				uni.showLoading({
					title: '提交中...'
				})
				this.disabled = true
				var token = uni.getStorageSync('token')
				uni.request({ //检查库存
					url: app.globalData.Domain_Name + '/GroupSeekCheckStockAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Seek_Purchase_SerialNumber: item.Group_Seek_Purchase_SerialNumber,
						Quantity: item.Quantity,
						token
					},
					success: (res) => {
						console.log(res.data);
						if (res.data.Status == 'success') {
							this.AgreePurchase(item, token)
						} else {
							uni.hideLoading()
							this.disabled = false
							this.type = 'error'
							this.message = '库存不足'
							this.LetterCommitment = true
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
						}
					}
				})
			},
			RefuseProcurement(item) {
				uni.showLoading({
					title: '提交中...'
				})
				this.disabled = true
				var token = uni.getStorageSync('token')
				uni.request({ //确认招采信息
					url: app.globalData.Domain_Name + '/GroupSeekTransactionExamineAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Seek_Transaction_SerialNumber: item.Group_Seek_Transaction_SerialNumber,
						Audit_Status: '2',
						Cause: '拒绝申请',
						token
					},
					success: (res) => {
						console.log(res.data);
						if (res.data.Status == 'success') {
							this.type = 'success'
							this.message = '已拒绝申请！'
							this.LetterCommitment = true
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
							this.disabled = false
							uni.hideLoading()
							this.show(this.form1)
						}
					}
				})
			},
			AgreePurchase(item, token) {
				uni.request({ //确认招采信息
					url: app.globalData.Domain_Name + '/GroupSeekTransactionExamineAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Seek_Transaction_SerialNumber: item.Group_Seek_Transaction_SerialNumber,
						Audit_Status: '1',
						Cause: '',
						token
					},
					success: (res) => {
						console.log(res.data);
						if (res.data.Status == 'success') {
							this.type = 'success'
							this.message = '已通过！'
							this.LetterCommitment = true
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
							this.disabled = false
							uni.hideLoading()
							this.show(this.form1)
						} else {
							this.type = 'error'
							this.message = '系统错误...'
							this.LetterCommitment = true
							setTimeout(() => {
								this.LetterCommitment = false
							}, 2000)
						}
					}
				})
			},
			getDatas(Group_Seek_Purchase_SerialNumber, Group_Seek_Transaction_SerialNumber) {
				uni.showLoading({
					title: '提交中...'
				})
				this.disabled = true
				var token = uni.getStorageSync('token')
				uni.request({ //确认招采信息
					url: app.globalData.Domain_Name + '/getGroupSeekProcureIDAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Seek_Purchase_SerialNumber,
						token
					},
					success: (res) => {
						this.form2 = res.data.Data
					}
				})
				let obj = {
					// 采购信息表
					group_seek_transaction: {
						group_seek_transaction_paystages: {}
					}
				}
				uni.request({ //确认招采信息
					url: app.globalData.Domain_Name + '/getSubtableInquiryOriginal',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Primary_Key: Group_Seek_Transaction_SerialNumber,
						JSONObject: JSON.stringify(obj),
						token
					},
					success: (res) => {
						this.formData = res.data.group_seek_transaction[0]
						this.ConfirmContract(this.form2, token)
					}
				})
			},
			ConfirmContract(item, token) {
				console.log(item)
				this.formData.Submission_Time = times.nowtime()
				this.formData.Enterprise_Info_SerialNumber = item.Enterprise_Info_SerialNumber
				this.formData.Group_Purchasing_SerialNumber = item.Group_Seek_Purchase_SerialNumber
				this.formData.Amount = item.Amount
				console.log(this.formData)
				var group_seek_message = {
					Group_Seek_Message_SerialNumber: "",
					Group_Seek_Transaction_SerialNumber: this.formData.Group_Seek_Transaction_SerialNumber,
					Cause: "确认合同",
					Submission_Time: times,
					Enterprise_Info_SerialNumber: uni.getStorageSync('enterprise'),
					Seller_Type: "0"
				}
				this.formData.Row_Status = '4'
				let data = {
					Data: JSON.stringify({
						Modify: {
							group_seek_transaction: [this.formData]
						},
						Add: {
							group_seek_message: [group_seek_message]
						}
					}),
					token,
				}
				uni.request({ //确认招采信息
					url: app.globalData.Domain_Name + '/getEditAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						uni.hideLoading()
						this.type = 'success'
						this.message = '已确认合同'
						this.LetterCommitment = true
						setTimeout(() => {
							this.LetterCommitment = false
							this.show(this.form1)
						}, 2000)
					}
				})
			},
			toggle(type, Group_Seek_Paystages_SerialNumber) {
				this.types = type
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open(type)
				this.codeUrl(Group_Seek_Paystages_SerialNumber)
				uni.setStorageSync('Group_Seek_Paystages_SerialNumber', Group_Seek_Paystages_SerialNumber)
			},
			ConfirmReceipt(item) { //确认收货
				uni.showLoading({
					title: '提交中...'
				})
				var token = uni.getStorageSync('token')
				item.Row_Status = '6'
				uni.request({
					url: app.globalData.Domain_Name + '/GroupSeekTransactionStateAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Group_Seek_Transaction_SerialNumber: item.Group_Seek_Transaction_SerialNumber,
						token
					},
					success: (res) => {
						uni.hideLoading()
						this.type = 'success'
						this.message = '已确认收货'
						this.LetterCommitment = true
						setTimeout(() => {
							this.LetterCommitment = false
							this.show(this.form1)
						}, 2000)
					}
				})
			},
			submit() {
				uni.showLoading({
					title: '提交中...'
				})
				setTimeout(() => {
					uni.hideLoading()
					this.type = 'success'
					this.message = '上传成功'
					this.LetterCommitment = true
					setTimeout(() => {
						this.LetterCommitment = false
					}, 2000)
					this.$refs.popup.close()
				}, 2000)
				var token = uni.getStorageSync('token')
				var Primary_Key = uni.getStorageSync('Group_Seek_Paystages_SerialNumber')
				uni.request({
					url: app.globalData.Domain_Name + '/GoodsInquiryKeyOriginal',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Primary_Key_Name: 'Group_Seek_Paystages_SerialNumber', //主键名
						Primary_Key, //主键值
						Data: 'group_seek_transaction_paystages',
					},
					success: (res) => {
						console.log(res);
						this.PaystagesData = res.data
						this.set(token)
					}
				})
			},
			getPayStage(item) {
				uni.request({ //查询
					url: app.globalData.Domain_Name + '/GoodsInquiryKey',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Primary_Key_Name: 'Group_Seek_Transaction_SerialNumber', //外键属性名
						Primary_Key: item.Group_Seek_Transaction_SerialNumber, //主键值
						Data: 'group_seek_transaction_paystages',
					},
					success: (res) => {
						console.log(res.data);
						this.TradingWay = res.data
					}
				})
			},
			set(token) {
				this.PaystagesData[0].Row_Status = 1
				this.PaystagesData[0].Collection_Amount = 0.01
				console.log(this.PaystagesData[0])
				let data = {
					Data: JSON.stringify({
						Modify: {
							group_seek_transaction_paystages: this.PaystagesData
						},
					}),
					token,
				}
				uni.request({
					url: app.globalData.Domain_Name + '/getEditAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						console.log(res);
						this.getPayStage(this.PaystagesData[0])
					}
				})
			},
			codeUrl(Group_Seek_Paystages_SerialNumber) {
				var token = uni.getStorageSync('token')
				uni.request({
					url: app.globalData.Domain_Name + '/GroupWeChatSeekNativeText',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						token,
						Group_Seek_Paystages_SerialNumber,
					},
					success: (res) => {
						console.log(res);
						this.payURL = res.data.code_url
					}
				})
			},
			getOr() {
				// uni.showLoading({
				// 	title:'提交中...'
				// })
				this.disabled = true
				var token = uni.getStorageSync('token')
				let _this = this;
				let obj = {
					// 采购信息表
					group_seek_transaction: {
						group_seek_transaction_paystages: {}
					}
				}
				console.log(this.group_seek_transaction_form.Group_Seek_Transaction_SerialNumber)
				uni.request({
					url: app.globalData.Domain_Name + '/getSubtableInquiryOriginal',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data: {
						Primary_Key: this.group_seek_transaction_form.Group_Seek_Transaction_SerialNumber,
						JSONObject: JSON.stringify(obj),
						token,
					},
					success: (res) => {
						console.log(res.data)
						this.getPayStage(res.data.group_seek_transaction[0])
						var Enterprise_Info_SerialNumber = res.data.group_seek_transaction[0]
							.Seller_Enterprise_Info_SerialNumber
						this.formData = res.data.group_seek_transaction[0]
						this.off(Enterprise_Info_SerialNumber, this.formData)
					}
				})
			},
			off(Enterprise_Info_SerialNumber, item) {
				console.log(item)
				var token = uni.getStorageSync('token')
				this.$refs.popup.close()
				this.formData.Row_Status = '7'
				var group_message_buyer = {
					Group_Message_SerialNumber: "",
					Group_Seek_Transaction_SerialNumber: item.Group_Seek_Transaction_SerialNumber,
					Cause: "对方已付款",
					Submission_Time: times.nowtime(),
					Enterprise_Info_SerialNumber,
					Seller_Type: "1"
				}
				console.log(group_message_buyer)
				let data = {
					Data: JSON.stringify({
						group_message: [group_message_buyer]
					}),
					token,
				}
				uni.request({
					url: app.globalData.Domain_Name + '/getAddAction',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					method: "POST",
					data,
					success: (res) => {
						uni.hideLoading()
						console.log(res.data)
						this.disabled = false
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	@mixin flex {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
	}

	@mixin height {
		/* #ifndef APP-NVUE */
		height: 100%;
		/* #endif */
		/* #ifdef APP-NVUE */
		flex: 1;
		/* #endif */
	}

	.active {
		color: #fc7c08;
		font-size: 40rpx;
		background-color: rgb(249, 249, 249);
	}

	.getPages {
		background-color: #fc7c08;
		color: #fff;
	}

	.bgc {
		background-color: #ffffff;
		cursor: pointer;
		transition: all 0.5s;
	}

	.popup-content {
		@include flex;
		align-items: center;
		justify-content: center;
		padding: 15px;
		background-color: #fff;
	}

	.demo-table-expand {
		font-size: 0;
	}

	.demo-table-expand label {
		width: 90px;
		color: #99a9bf;
	}

	.demo-table-expand .el-form-item {
		margin-right: 0;
		margin-bottom: 0;
		width: 50%;
	}
</style>